const express = require ('express')
const app = express()
//定义中间件函数
//注册中间件函数
//全局生效
app.use((req,res,next)=>{
    console.log('this is a mw func')
    const time = Date.now()
    //为req挂载时间属性，并共享到下游路由中
    req.arivetime = time
    next()
})

app.get('/',(req,res)=>{
    console.log('经过了/')
    res.send('home page  ' + req.arivetime)
})  
app.post('/user',(req,res)=>{
    console.log('经过了/user')
    res.send('user page  ' + req.arivetime)
})
app.listen(80,()=>{
    console.log('server running')
    
})